{% for pi_item in device_abstract_config.get('physical_interfaces',[]) %}
{%     if pi_item.get('comment') == 'Underlay Infra BMS Access' %}
{%         set pi_interface_name = pi_item.name %}
{%         for li_item in pi_item.get('logical_interfaces', []) %}
{%             if li_item.get('ip_addresses') is defined %}
{%                 set ip_address_list = li_item.get('ip_addresses',[]) %}
{%                 for ip_item in ip_address_list %}
set groups {{cfg_group}} interfaces {{pi_interface_name}} unit {{li_item.unit}} family {{ip_item.family}} address {{ip_item.address}}
{%                 endfor %}
{%             endif %}
{%             if li_item.get('family') is defined %}
{%                 if li_item.get('family') == 'ethernet-switching' %}
set groups {{cfg_group}} interfaces {{pi_interface_name}} unit {{li_item.unit}} family ethernet-switching vlan-id {{li_item.unit}}
{%                 endif %}
{%             else %}
set groups {{cfg_group}} interfaces {{pi_interface_name}} unit {{li_item.unit}} vlan-id {{li_item.unit}}
{%             endif %}
{%         endfor %}
{%     endif %}
{% endfor %}
{% for vlan_item in device_abstract_config.get('vlans',[]) %}
{%     if vlan_item.get('comment') == 'Underlay Infra BMS Access' %}
{%         set l3_intf = vlan_item.get('l3_interface') %}
set groups {{cfg_group}} vlans {{vlan_item.name}} vlan-id {{vlan_item.vlan_id}}
set groups {{cfg_group}} vlans {{vlan_item.name}} l3-interface {{l3_intf}}
{%     endif %}
{% endfor %}
{% set forwarding_options_item = device_abstract_config.get('forwarding_options',{}) %}
{% for relay_item in forwarding_options_item.get('dhcp_relay',[]) %}
{%     if relay_item.get('comment') == "Underlay Infra BMS Access" %}
{%     set dhcp_relay_grp = relay_item.get('dhcp_relay_group') %}
set groups {{cfg_group}} forwarding-options dhcp-relay overrides bootp-support
set groups {{cfg_group}} forwarding-options dhcp-relay group {{dhcp_relay_grp}} active-server-group SVR-MGR
{%         for dhcp_ips in relay_item.get('dhcp_server_ips',[]) %}
set groups {{cfg_group}} forwarding-options dhcp-relay server-group SVR-MGR {{dhcp_ips.address}}
{%         endfor %}
{%         for intrf_item in relay_item.get('interfaces',[]) %}
set groups {{cfg_group}} forwarding-options dhcp-relay group {{dhcp_relay_grp}} interface {{intrf_item.name}}
{%         endfor %}
{%     endif %}
{% endfor %}
